package com.slipper.system.codeless.controller;

import com.slipper.constants.Constants;
import com.slipper.util.ResultUtil;
import com.slipper.util.Tool;
import com.slipper.system.codeless.bo.PageCompBO;
import com.slipper.system.codeless.service.PageCompService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

/**
 * 页面组件信息表
 */
@RestController
@RequestMapping("/system/pageComp")
public class PageCompController {
    @Resource
    private PageCompService pageCompService;
    
    @PostMapping(value = "/queryBy")
    public String queryBy(@RequestBody PageCompBO bo) {
        if(Tool.isBlank(bo.getId())) {
            return ResultUtil.failureResult("数据获取失败！");
        }
        return ResultUtil.successResult(pageCompService.queryBy(bo.getId()));
    }

    @PostMapping(value = "/save")
    public String save(@RequestBody PageCompBO bo) {
        bo.setOperateId(Constants.getCurrentUser().getEmployeeId());
        return ResultUtil.saveResult(pageCompService.save(bo));
    }
}
